<?php
namespace app\admin\logic;


class OrderLogic
{
    //订单列表where条件
    public static function orderWhere($param)
    {
        $where = [];
        if (isset($param['keywords']) && !empty($param['keywords'])){
            $where[] = ['o.order_sn','like','%'.$param['keywords'].'%'];
        }
        if (isset($param['minTime']) && !empty($param['minTime'])){
            $min = strtotime($param['minTime']);
            $where[] = ['o.add_time','>',$min];
        }
        if (isset($param['maxTime']) && !empty($param['maxTime'])){
            $max = strtotime($param['maxTime']);
            $where[] = ['o.add_time','<',$max];
        }
        if (isset($param['status'])){
            $where[] = ['os.status_id','in',$param['status']];
        }
        if (isset($param['minAmount']) && !empty($param['minAmount'])){
            $where[] = ['o.order_amount','>',$param['minAmount']];
        }
        if (isset($param['maxAmount']) && !empty($param['maxAmount'])){
            $where[] = ['o.order_amount','<',$param['maxAmount']];
        }
        return $where;
    }
    //订单列表留值
    public static function orderData($param)
    {
        $data = [
            'keywords'=>isset($param['keywords'])?$param['keywords']:'',
            'minTime'=>isset($param['minTime'])?$param['minTime']:'',
            'maxTime'=>isset($param['maxTime'])?$param['maxTime']:'',
            'status'=>isset($param['status'])?$param['status']:[],
            'minAmount'=>isset($param['minAmount'])?$param['minAmount']:'',
            'maxAmount'=>isset($param['maxAmount'])?$param['maxAmount']:'',
        ];
        return $data;
    }


}
